// import _ from 'lodash'
import {
  getWorkShop
} from 'src/boot/job/process-order'
import {
  getDeviceIds
} from 'src/boot/maintenance/maintenance-plan'
import {
  getMaintainContent
} from 'src/boot/maintenance/maintenance-item'
// 获取所在车间
function getWorkshopsList ({ commit }) {
  return getWorkShop().then(res => {
    commit('SET_WORKSHOPSLIST', res.data)
    return res.data
  }).catch(err => {
    commit('SET_WORKSHOPSLIST', [])
    console.log(err)
  })
}
// 获取车间设备
function getDeviceIdList ({ commit }, params) {
  return getDeviceIds(params).then(res => {
    return res.data.list
  }).catch(err => {
    console.log(err)
  })
}
// 获取设备类型
function getDeviceTypesList ({ commit }, disable) {
  return getMaintainContent(disable, 'machine_type').then(res => {
    commit('SET_DEVICETYPESLIST', res)
  }).catch(err => {
    commit('SET_DEVICETYPESLIST', [])
    console.log(err)
  })
}
// 获取项目内容
function getMaintainItemContent ({ commit }, disable) {
  return getMaintainContent(disable).then(res => {
    commit('SET_MAINTAINITEMCONTENT', res)
    return res
  }).catch(err => {
    commit('SET_MAINTAINITEMCONTENT', [])
    console.log(err)
  })
}
export default {
  getWorkshopsList,
  getDeviceTypesList,
  getDeviceIdList,
  getMaintainItemContent
}
